home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / vncviewer < prev    next >
Encoding:
Text File  |  2010-11-16  |  3.9 KB  |  131 lines

  1. # bash completion for vncviewer
  2.  
  3. have vncviewer &&
  4. _vncviewer_bootstrap()
  5. {
  6.     local fname
  7.     case $(_realcommand vncviewer) in
  8.         *xvnc4viewer)      fname=_xvnc4viewer    ;;
  9.         *tightvncviewer)   fname=_tightvncviewer ;;
  10.         *)                 fname=_known_hosts    ;;
  11.     esac
  12.  
  13.     # Install real completion for subsequent completions
  14.     complete -F $fname vncviewer
  15.     $fname  # Generate completions once for now
  16.     unset -f _vncviewer_bootstrap
  17. } &&
  18. complete -F _vncviewer_bootstrap vncviewer
  19.  
  20. have tightvncviewer &&
  21. _tightvncviewer()
  22. {
  23.     local cur prev
  24.  
  25.     COMPREPLY=()
  26.     _get_comp_words_by_ref cur prev
  27.  
  28.     case $prev in
  29.         -passwd)
  30.             _filedir
  31.             return 0
  32.             ;;
  33.         -encodings)
  34.             COMPREPLY=( $( compgen -W 'copyrect tight hextile zlib \
  35.                 corre rre raw' -- "$cur" ) )
  36.             return 0
  37.             ;;
  38.         -via)
  39.             _known_hosts_real "$cur"
  40.             return 0
  41.             ;;
  42.     esac
  43.  
  44.  
  45.     if [[ "$cur" == -* ]]; then
  46.         COMPREPLY=( $( compgen -W '-help -listen -via -shared -noshared\
  47.             -viewonly -fullscreen -noraiseonbeep -passwd -encodings\
  48.             -bgr233 -owncmap -truecolour -truecolor -depth \
  49.             -compresslevel -quality -nojpeg -nocursorshape \
  50.             -x11cursor' -- $cur ) )
  51.     else
  52.         _known_hosts_real "$cur"
  53.     fi
  54. } &&
  55. complete -F _tightvncviewer tightvncviewer
  56.  
  57.  
  58. # NOTE: - VNC Viewer options are case insensitive.
  59. #         Preferred case is taken from -help.
  60. #       - Both single dash (-) and double dash (--) are allowed as option prefix
  61. have xvnc4viewer &&
  62. _xvnc4viewer()
  63. {
  64.     local cur prev
  65.  
  66.     COMPREPLY=()
  67.     _get_comp_words_by_ref cur prev
  68.  
  69.     # Convert double dash to single dash
  70.     case ${prev/#--/-} in
  71.         # -passwd, -PasswordFile
  72.         -[pP][aA][sS][sS][wW][dD]|-[pP][aA][sS][sS][wW][oO][rR][dD][fF][iI][lL][eE])
  73.             _filedir
  74.             return 0
  75.             ;;
  76.         # -PreferredEncoding
  77.         -[pP][rR][eE][fF][eE][rR][rR][eE][dD][eE][nN][cC][oO][dD][iI][nN][gG])
  78.             COMPREPLY=( $( compgen -W 'zrle hextile raw' -- $cur ) )
  79.             return 0
  80.             ;;
  81.         # -via
  82.         -[vV][iI][aA])
  83.             _known_hosts_real "$cur"
  84.             return 0
  85.             ;;
  86.     esac
  87.  
  88.     if [[ "$cur" == -* || "$cur" == --* ]]; then
  89.         # Default to vncviewer camelcase options, see `vncviewer -help'
  90.         local dash options=( \
  91.             AcceptClipboard AutoSelect DebugDelay display \
  92.             DotWhenNoCursor FullColor FullColour FullScreen \
  93.             geometry help listen Log \
  94.             LowColourLevel MenuKey name Parent \
  95.             passwd PasswordFile PointerEventInterval PreferredEncoding \
  96.             SendClipboard SendPrimary Shared UseLocalCursor \
  97.             via ViewOnly WMDecorationHeight WMDecorationWidth \
  98.             ZlibLevel \
  99.         )
  100.         [[ "$cur" == --* ]] && dash=-- || dash=-
  101.         # Is a `nocasematch' variable available (bash > v3.1)?
  102.         if shopt nocasematch 2> /dev/null | command grep -q ^nocasematch; then
  103.             # Variable `nocasematch' is available
  104.             # Use vncviewer camelcase options
  105.             local option oldNoCaseMatch=$(shopt -p nocasematch)
  106.             shopt -s nocasematch
  107.             COMPREPLY=( $( for option in "${options[@]}"; do
  108.                 [[ $dash$option == "$cur"* ]] && printf '%s\n' $dash$option
  109.             done ) )
  110.             eval "$oldNoCaseMatch" 2> /dev/null
  111.         else
  112.             # Variable 'nocasematch' isn't available;
  113.             # Convert completions to lowercase
  114.             COMPREPLY=( $( compgen -W \
  115.                 "$( tr [:upper:] [:lower:] <<<${options[@]/#/$dash} )" \
  116.                 -- "$( tr [:upper:] [:lower:] <<<"$cur" )" ) )
  117.         fi
  118.     else
  119.         _known_hosts_real "$cur"
  120.     fi
  121. } &&
  122. complete -F _xvnc4viewer xvnc4viewer
  123.  
  124. # Local variables:
  125. # mode: shell-script
  126. # sh-basic-offset: 4
  127. # sh-indent-comment: t
  128. # indent-tabs-mode: nil
  129. # End:
  130. # ex: ts=4 sw=4 et filetype=sh
  131.